import 'dart:convert';
import 'package:cloud_medicine/components/util.dart';
import 'package:cloud_medicine/http/HttpUtil.dart';
import 'package:cloud_medicine/http/config.dart';
import 'package:dio/dio.dart';

// 获取帖子消息列表
Future getPostMessageList_api() async {
  String token = await getToken();
  Response res = await HttpUtil.request(
    '$backIP/message/post',
    method: HttpUtil.GET,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}

// 获取帖子消息列表
Future getNoticeMessageList_api() async {
  String token = await getToken();
  Response res = await HttpUtil.request(
    '$backIP/message/notice',
    method: HttpUtil.GET,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}

// 获取会诊消息列表
Future getDiscussMessageList_api() async {
  String token = await getToken();
  Response res = await HttpUtil.request(
    '$backIP/message/doctor',
    method: HttpUtil.GET,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}

// 获取会诊消息具体信息
Future getDiscussMessageDetail_api(Map<String, dynamic> data) async {
  String token = await getToken();
  Response res = await HttpUtil.get(
    '$backIP/message',
    parameters: data,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}

// 移除消息
Future deleteMessage_api(Map<String, dynamic> data) async {
  String token = await getToken();
  Response res = await HttpUtil.request(
    '$backIP/message',
    method: HttpUtil.DELETE,
    parameters: data,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}

// 移除消息
Future agreeMessage_api(Map<String, dynamic> data) async {
  String token = await getToken();
  Response res = await HttpUtil.request(
    '$backIP/message/agree',
    method: HttpUtil.POST,
    parameters: data,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}

// 发送消息给医生
Future sendMessageToDoctor_api(Map<String, dynamic> data) async {
  String token = await getToken();
  Response res = await HttpUtil.request(
    '$backIP/message/notice',
    method: HttpUtil.POST,
    parameters: data,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}